﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NLUNZ.Admin
{
    public partial class Default : System.Web.UI.Page
    {
        public CompanyInfo LatestNews { get; set; }
        public List<CompanyInfo> NewsList { get; set; }
        public List<Partner> Partners { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            LoadNews();
            LoadPartner();
        }

        private void LoadPartner()
        {
            Partners = Repository.GetAllPartners();
        }

        private void LoadNews()
        {
            List<CompanyInfo> latestNews = Repository.GetLatestNews(6);
            if (latestNews.Count > 0)
            {
                //get the top 1 news
                LatestNews = latestNews[0];

                if (latestNews.Count > 1)
                {
                    NewsList = latestNews.Skip(1).ToList();
                }
            }
        }

        protected void RadTextBoxTracking_TextChanged(object sender, EventArgs e)
        {
            SearchTracking();
        }

        private void SearchTracking()
        {
            //redirect to Search Result Page
        }
        protected void Signout_Click(object sender, EventArgs e)
        {
            FormsAuthentication.SignOut();
            Response.Redirect("~/Admin/Login.aspx");
        }

        protected void btnEditPartners_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Admin/EditPartners.aspx");
        }

        protected void btnEditNews_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Admin/EditNews.aspx");
        }

        protected void btnEditTracking_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Admin/TrackingEdit.aspx");
        }

        protected void btnEditMembership_Click(object sender, EventArgs e)
        {

        }

    }
}